/*
 * @Description:
 * @Author: wangyan
 * @Date: 2021-02-26 08:54:49
 * @LastEditTime: 2021-03-13 10:34:39
 * @LastEditors: Please set LastEditors
 */
import { deletClassifyById, addClassify, listClassify, pageClassify, updateClassify } from "@/api/flowClassifyApi";

export default {
    namespaced: true,
    state: () => ({
        treeData: []
    }),
    getter: {},
    actions: {
        async getFlowList({ state }) {
            console.log('getFlowList');
            const rst = await listClassify();
            if (rst.data.success) {
                state.treeData = rst.data.data
                return rst.data;
            } else {
                return false
            }
        },
        async pageClassify(context, payload) {
            console.log(payload)
            const rst = await pageClassify(payload.pageOption, payload.data);
            if (rst.data.success) {
                return rst.data.data;
            } else {
                return false
            }
        },
        async deleteFlowById(context, payload) {
            const rst = await deletClassifyById(payload);
            if (rst.data.success) {
                return rst.data.data;
            } else {
                return false
            }
        },
        async addFlow(context, payload) {
            const rst = await addClassify(payload);
            if (rst.data.success) {
                return rst.data.data;
            } else {
                return false
            }

        },
        async updateClassify(context, payload) {
            const rst = await updateClassify(payload);
            if (rst.data.success) {
                return rst.data.data;
            } else {
                return false
            }
        }
    },
    mutations: {

    }
}
